package com.qf.business.user.task;

import com.qf.business.user.service.RedEnvelopesService;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 红包回退的定时任务
 * description:
 * author: Ken
 * 公众号：Java架构栈
 */
@Component
@Slf4j
public class RedBackTimerTask {

    @Autowired
    private RedEnvelopesService redEnvelopesService;

    /**
     * 红包回退 - 每隔10分钟触发一次这个方法
     */
    @XxlJob("redback")
    public void redBack(){
        //查询数据库，找到所有未抢完并且已经过期的红包，进行回退处理
        log.info("[red back] - 红包退回的业务触发！");
        redEnvelopesService.redBack();
    }
}
